<template style="container-type:inline-size">
  <div class="father-box">
  <main class="resume" >
    <section class="resume-header">
      <div class="line-container basic">
        <h1>{{ basicInfo.name }}</h1>
        <h2>求职意向：
          <h2 v-for="item in objectives"
          style="display: inline;margin-right: 1.5cqw;">{{ item.position }}</h2>
        </h2>
      </div>
      <div class="line-container contact">
        <p>{{ basicInfo.phone }}</p>
        <p>{{ basicInfo.email }}</p>
      </div>
      <div class="resume-photo">
        <!-- <img src="/src/assets/images/IDphoto/白底证件照.png" alt="样例证件照"> -->
      </div>
    </section>

    <section class="resume-content">

      <div class="resume-section" v-if="educations.length">
        <h2>教育背景<span></span>EDUCATION</h2>
        <div class="timeline-item" v-for="edu in educations">
          <div class="timeline-header">
            <span class="timeline-period" v-if="edu.duration">{{ formatDateRange(edu.duration) }}</span>
            <span class="timeline-title">{{ edu.school }}·{{ edu.major }}
              <span style="margin-left: 5cqw;">{{ edu.gradeType }}：{{ edu.grade }}</span>
            </span>
          </div>

          <div class="timeline-content">
            <ul class="course-list">
              <li v-for="item in edu.courses">{{ item.name }}({{ item.score }})</li>
            </ul>
            
          </div>

        </div>
      </div>

      
      <div class="resume-section" v-if="awards.length">
        <h2>获奖经历<span></span>AWARDS</h2>
        <ul class="xxx-list">
          <ul>
            <li v-for="a in awards">
              <span class="award-name">{{ a.name }}</span>
              <span class="award-date" v-if="a.date">{{ formatStringDate(a.date) }}</span>
            </li>
          </ul>
        </ul>
      </div>

      <div class="resume-section" v-if="projects.length">
        <h2>项目经历<span></span>EXPERIENCE</h2>
          <div class="timeline-item" v-for="pro in projects">
            <div class="timeline-header">
              <span class="timeline-period" v-if="pro.duration">{{ formatDateRange(pro.duration) }}</span>
              <span class="timeline-title">{{ pro.name }}<span>·{{ pro.role }}</span></span>
            </div>
            <div class="timeline-content">
              <ul>
                <li>{{ pro.description }}</li>
              </ul>
            </div>
          </div>
      </div>

      <div class="resume-section" v-if="skills.length">
        <h2>专业技能<span></span>SKILLS</h2>
        <ul class="xxx-list">
          <ul>
            <li v-for="s in skills">
              <span>{{ s.name }}</span>
              <span>{{ s.proficiency }}</span>
            </li>
          </ul>
        </ul>
      </div>

      <div class="resume-section" v-if="campusExperiences.length">
        <h2>在校经历<span></span>CAMPUS</h2>
        <div class="timeline">
          <div class="timeline-item" v-for="cam in campusExperiences">
            <div class="timeline-header">
              <span class="timeline-period" v-if="cam.duration">{{ formatDateRange(cam.duration) }}</span>
              <span class="timeline-title">{{ cam.organization }}·{{ cam.position }}</span>
            </div>
            <div class="timeline-content">
              <ul>
                <li>参与制作5项活动宣传物料（晚会海报/团史册/易拉宝等），印刷物料覆盖校内十余个宣传点位</li>
                
              </ul>
            </div>
          </div>
          
        </div>
      </div>

      

    </section>
  </main>
  
  </div>
</template>

<script setup>

import { computed } from 'vue'

const props = defineProps({
  colorTemplate: {
    type: Array,
    default: () => ['#1890ff', '#909399', '#000000']
  },
  initialData: {
    type: Object,
    required: true
  },
})



// 更新数据映射关系
const basicInfo = computed(() => props.initialData.basic || {})
const educations = computed(() => props.initialData.education || [])
const workExperiences = computed(() => props.initialData.workExperience || [])
const projects = computed(() => props.initialData.projects || [])
const skills = computed(() => props.initialData.skills || [])
const campusExperiences = computed(() => props.initialData.campusExperience || [])
const objectives = computed(() => props.initialData.jobObjectives || [])
const awards = computed(() => props.initialData.awards || [])

// 格式化日期（精确到月）
const formatStringDate = (date) => {
  date = new Date(date);
  return date.toISOString().slice(0,7);
}

// 格式化日期范围（精确到月）
const formatDateRange = (range) => {
  const date1 = new Date(range[0]);
  const date2 = new Date(range[1]);
  return date1.toISOString().slice(0,7).replace('-','.')+' - '+date2.toISOString().slice(0,7).replace('-','.');
}


</script>


<style scoped>
*{
  text-align: left;
  font-weight: normal;
}

.resume {
  background-color: white;
  height: auto;
  border: 3.5cqw solid rgb(240, 240, 240);
  background-clip: content-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.resume-header {
  height: 16cqw;
  width: 86cqw;
  background-color: #2E75B6;
  color: white;
  line-height: 5cqw;
  position: relative;
  margin-top: 4cqw;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}

.resume-photo {
  position: absolute;
  right: 6cqw;
  top: -2cqw;
  height: 20cqw;
  width: auto;
  aspect-ratio: 5/7;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  overflow: hidden;
  display: flex;
  justify-content: center;
  img{
    height: 20cqw;
    object-fit: cover;
  }
}
.resume-header::before{
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  border-left: .8cqw solid transparent;
  border-bottom: .8cqw solid transparent;
  border-top: .8cqw solid #0f4a6e;
  border-right: .8cqw solid #0f4a6e;
  top: 16cqw;
}
.resume-header::after{
  content: '';
  position: absolute;
  width: 0;
  height: 0;
  right: 0cqw;
  top: 16cqw;
  border-right: .8cqw solid transparent;
  border-bottom: .8cqw solid transparent;
  border-top: .8cqw solid #0f4a6e;
  border-left: .8cqw solid #0f4a6e;
}
.line-container{
  display: flex;
  align-items: center;
  margin-left: 6cqw;
  h1 {
    font-size: 4cqw;
    font-weight: 800;
    margin: 0;
    margin-right: 8cqw;
  }
  h2 {
    font-size: 2.25cqw;
  }
  p{
    margin: 0;
    font-size: 1.75cqw;
    margin-right: 4cqw;
  }
}

.resume-section {
  margin: 4cqw 3cqw;
  /* border: 1px solid #b5b5b5; */
  h2{
    font-size: 2cqw;
    font-weight: 800;
    color: #2E75B6;
    margin-bottom: 1.2cqw;
    padding-bottom: .8cqw;
    border-bottom: 2px solid #67a7e3;
    span{
      padding: 3cqw;
    }
  }
}

/* 数据项 */
.timeline-item {
  max-width: 100cqw;
}

.timeline-header {
  display: flex;
  margin-bottom: .5cqw;
  span{
    font-size: 1.8cqw;
    font-weight: 800;
  }
  .timeline-period{
    width: 20cqw;
    margin-right: 5cqw;
  }
  .timeline-title{
    span{
      font-weight: 500;
    }
  }
}

.timeline-content{
  font-size: 1.7cqw;
  font-weight: 600;
  margin-bottom: 1cqw;
}

.timeline-content ul {
  list-style: none;
  padding: 0;
  li {
    padding-left: 2cqw;
    margin-bottom: .3cqw;
    position: relative;
  }
}

.timeline-content li::before {
  content: '•';
  color: #2E75B6;
  position: absolute;
  left: 0;
}



/* 教育部分 */

.course-list {
  display: inline-block;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  /* margin-left: 2cqw; */
}
.course-list li {
  font-size: 1.6cqw;
  margin: 0 1cqw;
  padding: 0;
  margin: 0;
}
.course-list li::before {
  content: '';
}
.course-list::before{
  content: '专业课程:';
  font-size: 1.7cqw;
  position: relative;
  top: -.1cqw;
  /* left: -1cqw; */
}

/* 奖项 */
.xxx-list {
  list-style: none;
  padding: 0;
  ul{
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: .5cqw;
    padding: 0;
    li{
      font-size: 1.6cqw;
      padding: 0 1cqw;
      margin-bottom: 0.3cqw;
      span:nth-child(1){
        padding-right: .5cqw;
      }
      span:nth-child(2){
        background: #acd7ff;
        color: white;
        font-size: 1cqw;
        font-weight: 500;
        padding: 0.1cqw 0.5cqw;
        border-radius: .5cqw;
        float: right;
      }
    }
  }
  ul>span{
    font-size: 1.6cqw;
    font-weight: 800;
    width: 100%;
    margin-bottom: 0.5cqw;
  }
}




/* @media (max-width: 768px) {
  .timeline-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }
} */

.personal-info {
  text-align: center;
  margin-top: 1rem;
}

.personal-info h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.personal-info p {
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.btns button {
  background: #2E75B6;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btns button:hover {
  background: #1a4d80;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

</style>
